let plugin_db = Hashtbl.create 117
let hooks_db = Hashtbl.create 117

let (|>) h w = Hashtbl.find h w
let (<|) h (w,v) = Hashtbl.replace h w v
let (|?) h w = Hashtbl.mem h w

let register s info = plugin_db<|(s,info)
let get_info s = plugin_db|>s
let get_list = Hashtbl.fold (fun s info l -> (s,info)::l) plugin_db []

let get_hook s = if hooks_db|?s then hooks_db|>s else []
let add_hook s f = let h = get_hook s in hooks_db<|(s,f::h)
let call_hook s arg = List.fold_left (fun acc f -> f acc) arg (List.rev (get_hook s))
